﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Storage;

namespace WCS.Repository.Interface
{
    /// <summary>
    /// 数据访问接口
    /// </summary>
    public interface IRepository<T> where T : class, new()
    {
        Task AddAsync(T t, CancellationToken cancellationToken = default);
        Task AddRangeAsync(IEnumerable<T> ie, CancellationToken cancellationToken = default);
        Task DeleteAsync(T t, CancellationToken cancellationToken = default);
        Task DeleteRangeAsync(IEnumerable<T> ie, CancellationToken cancellationToken = default);
        Task UpdateAsync(T t, CancellationToken cancellationToken = default);
        Task UpdateRangeAsync(IEnumerable<T> ie, CancellationToken cancellationToken = default);
        Task<T?> FindAsync(params object?[]? values);
        Task<T?> FindAsync(object?[]? values, CancellationToken cancellationToken = default);
        Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);

        IQueryable<T> QueryAll(Expression<Func<T, bool>>? where);

        IQueryable<T> QueryAll<type>(Expression<Func<T, bool>>? where, Expression<Func<T, type>>? order, bool isAsc = true);

        IQueryable<T> QueryAll<type>(out int total, int skip, int take, Expression<Func<T, bool>>? where, Expression<Func<T, type>>? order, bool isAsc = true);
    }
}
